package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PremisesApiService;
import com.yixun.qfbao.apidto.GetPremisesForOtherReqDto;
import com.yixun.qfbao.apidto.GetPremisesForOtherResDto;
import com.yixun.qfbao.config.DistributionConfig;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetPremisesForOtherReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @Description 获取楼盘信息
 * @Date 2018/1/10
 * @Author sangtao
 * @Computer Administrator
 */
@Service("getPremisesForOtherHander")
public class GetPremisesForOtherHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetPremisesForOtherHander.class);
    @Autowired
    private PremisesApiService premisesService;
    @Autowired
    private DistributionConfig distributionConfig;

    @SuppressWarnings("rawtypes")
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetPremisesForOtherReqVo req = (GetPremisesForOtherReqVo)reqDto;
        GetPremisesForOtherReqDto reqDto1 = req.getParams();
        BaseResponseDTO<GetPremisesForOtherResDto> res = new BaseResponseDTO<GetPremisesForOtherResDto>();
        GetPremisesForOtherResDto resDto = new GetPremisesForOtherResDto();
        try {
            reqDto1.setDevCompany(Long.parseLong(distributionConfig.getDevCompany()));
            resDto = premisesService.getPremisesListForOther(reqDto1);
        } catch (Exception e) {
            logger.error("GetPremisesForOtherHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setMessage("楼盘获取失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
